from django.db import models
from usercenter.modelfields import jsonfield


class CustomerProfile(models.Model):

    CUSTOMER_STATUS_CHOICES = (
        ('ok', '正常'),
        ('abnormal', '异常用户'),
    )

    username = models.CharField(
        '姓名',
        max_length=30,
        help_text='姓名',
    )

    cellphone = models.CharField(
        '手机',
        max_length=30,
        help_text='手机',
        db_index=True,
        default='',
    )

    email = models.CharField(
        '邮箱',
        max_length=100,
        help_text='邮箱',
        db_index=True,
        default='',
    )

    wechat_openid = models.CharField(
        '微信openid',
        max_length=200,
        help_text='微信openid',
        db_index=True,
        default='',

    )

    qq_openid = models.CharField(
        'QQ openid',
        max_length=200,
        help_text='QQ openid',
        db_index=True,
        default='',
    )

    status = models.CharField(
        '状态',
        choices=CUSTOMER_STATUS_CHOICES,
        blank=True,
        max_length=20,
        default='ok',
        help_text='状态',
    )

    wechat_user_info = jsonfield.JSONField(
        u'微信用户信息',
        default={},
        blank=True,
        help_text=u'微信用户信息',
    )

    qq_user_info = jsonfield.JSONField(
        u'QQ用户信息',
        default={},
        blank=True,
        help_text=u'QQ用户信息',
    )

    password = models.CharField(
        '密码hash',
        blank=True,
        max_length=200,
        default='',
        help_text='密码hash',
    )

    def __str__(self):
        return self.username

    class Meta:
        verbose_name = '客户信息'
        verbose_name_plural = verbose_name